<%@ page language="java"
import="java.util.*,com.wechat.service.WechatService,
com.base.bean.*,com.base.dao.*,com.base.service.*,tool.*"
pageEncoding="UTF-8"%>

<%


String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() +  path + "/"; 

WechatService ws = WechatService.getInstance(); 
//ValueStack vs=(ValueStack)request.getAttribute("struts.valueStack");
//String openId=(String)vs.findValue("openId");
//String photoUrl=(String)vs.findValue("photoUrl");
String url = basePath+"xd_do";
//String url = basePath + "actvt"+"?openId="+openId;


%>

<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="json" uri="http://www.atg.com/taglibs/json" %>  

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css">

<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/main.css">    
<script src="lib/jquery-2.1.1.min.js"></script>
<script src="lib/bootstrap/js/bootstrap.min.js"></script>
<title>HIFO--行动管理</title>



<script type="text/javascript">
function tijiao(){
$('#type').val($('#_type').val());	
$('#memo').val($('#_memo').val());
$('#name').val($('#_name').val());
$('#state').val('b');
document.form1.submit();
//alert("提交成功");
}

</script>
</head>
<body>
<%@ include file="_daohang.jsp" %>	


<div class="row">
    <div class="col-xs-12"><s:property value="tip"/></div>    
</div> 


<div class="panel-body">
           
<!-- ################# form START ###################  -->

<form name="form1" action="xd_do" method="post">

<!-- 隐藏数据域  START -->
<div class="input-group hide">
<input type="text" class="form-control" name="openId" readonly="readonly" value="<s:property value="openId"/>" >
<input type="text" class="form-control" id="longitude" name="longitude" value="<s:property value="longitude"/>" >
<input type="text" class="form-control" id="latitude" name="latitude" value="<s:property value="latitude"/>" >
<input type="text" class="form-control" id="imgIds" name="imgIds" value="<s:property value="imgIds"/>" >
<input type="text" class="form-control" id="cid" name="cid" value="<s:property value="cid"/>" >

<input type="text" class="form-control" id="name" name="name" value="<s:property value="name"/>" >
<input type="text" class="form-control" id="memo" name="memo" value="<s:property value="memo"/>" >
<input type="text" class="form-control" id="type" name="type" value="<s:property value="type"/>" >

<input type="text" class="form-control" id="state" name="state" value="" >

<button class="form-control" id="checkJsApi">checkJsApi</button>
</div>
<!-- 隐藏数据域  END -->
</form>


<div class="row">
    <div class="col-xs-5 col-xs-offset-2" ><a href="kh_do?openId=<s:property value="openId"/>"><img class="home" id="nameImg" src="images/search.png" >选择客户</a></div>
    <div class="col-xs-5"><img class="home" id="nameImg" src="images/order.png"></div>
    <div class="col-xs-12">
    <p class="bg-warning">注意:只有“电话拜访”无需照片以及位置信息</p>
    </div>
</div>

<div class="input-group">
<div class="input-group-addon"><img class="home" id="nameImg" src="images/name.png"></div>
<input type="text" class="form-control" id="_name" name="_name" readonly="readonly" value="<s:property value="cb.name"/>" >
</div>

<div class="input-group">

<div class="input-group-addon">&lowast;<img class="home" id="nameImg" src="images/zanwei.png"></div>
<s:select id="_type" name="_type" cssClass="form-control" list="#{0:'行动类型（请选择）',9:'电话拜访',1:'空白市场开发',2:'二级渠道开发',3:'新客户拜访',4:'老客户拜访',5:'商务谈判',6:'交机',8:'客户催款',10:'小挖开发',11:'电话催收',7:'备注其他'}" 
listKey="key" listValue="value" />
</div>

<div class="input-group">
<div class="input-group-addon">&lowast;<img class="home" id="nameImg" src="images/zanwei.png"></div>
<button id="getLocation" class="form-control btn btn-default" ><img class="home" id="nameImg" src="images/gps.png"><span>当前位置</span></button>
</div>

<div class="input-group">
<div class="input-group-addon">&lowast;<img class="home" id="nameImg" src="images/zanwei.png"></div>
<div class="row">
    <div class="col-xs-6"><button id="chooseImage" class="form-control btn btn-default" >拍照</button></div>
    <div class="col-xs-6"><button id="uploadImage" class="form-control btn btn-default" >上传</button></div>    
</div>
</div>
    
<div class="input-group">
<div class="input-group-addon"><img class="home" src="images/memo.png"></div>
<textarea class="form-control" rows="2" cols="10" id="_memo" name="_memo"></textarea>
</div>



<!-- ############### form end ############## -->

<div class="row">
<hr>

<div class="col-xs-6"></div>
<div class="col-xs-6"><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">提交</button></div>

<hr>
<div  class="panel-body">

<table class="table table-condensed">
<tr class="success">
<td colspan="5" class="info"><s:property value="datetime"/>---显示最近20条记录(当月有效数:<s:property value="monthTotal"/>条)</td>
</tr>

<s:iterator value="actvtList" id="as" status="index">
<tr class="success">

<td class="active" width="50">
<s:if test='#as.checked==0'>
待审
</s:if>
<s:elseif test='#as.checked==1'>
通过
</s:elseif>
<s:elseif test='#as.checked==2'>
无效
</s:elseif>
<s:elseif test='#as.checked==3'>
重复
</s:elseif>
<s:elseif test='#as.checked==4'>
其他
</s:elseif>

</td>


<td class="active" width="50"><s:property value="#as.created.toString().substring(5,10)"/></td>
<td class="active" width="50"><s:property value="#as.created.toString().substring(11,16)"/></td>
<td class="active"><s:property value="#as.clientName"/></td>
<s:if test="as.type==0" >
<td class="active"></td>
</s:if>
<s:if test="as.type==1" >
<td class="active">空白市场</td>
</s:if>
<s:if test="as.type==2" >
<td class="active">渠道开发</td>
</s:if>
<s:if test="as.type==3" >
<td class="active">访新客户</td>
</s:if>
<s:if test="as.type==4" >
<td class="active">访老客户</td>
</s:if>

<s:if test="as.type==5" >
<td class="active">商务谈判</td>
</s:if>
<s:if test="as.type==6" >
<td class="active">交机行动</td>
</s:if>
<s:if test="as.type==7" >
<td class="active">备注</td>
</s:if>
<s:if test="as.type==8" >
<td class="active">催款行动</td>
</s:if>

<td class="active" width="40"><a class="btn btn-default" href="http://we.51waji.com/picture/<s:property value="#as.path"/>/<s:property value="#as.photoName"/>" role="button">查看</a></td>
</tr>
 <tr class="active">
<td colspan="5" class="active"><s:property value="#as.content"/></td>
</tr>

 <tr class="default">
<td colspan="5" class="active">审核备注：<s:property value="#as.checkmemo"/></td>
</tr>

</s:iterator> 

</table>

</div><!-- panel-body -->

</div>

</div><!--form-group-->
<!-- ################基本信息 END   ###########################       -->           
           
           
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<!--此处可以加入很多信息-->
<div class="modal-body">
    <input type="button" class="btn btn-primary" value="确定提交"  onClick="tijiao()"  />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>

</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!--按钮触发模态框 END -->           
           
           
 				
				
  




			

</body>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

<script><%=ws.wxConfig(url) %></script>

<script>

var images = {
		    localId: [],
		    serverId: []
		  };


wx.ready(function () {
// 1 判断当前版本是否支持指定 JS 接口，支持批量判断
document.querySelector('#checkJsApi').onclick = function () {
  wx.checkJsApi({
    jsApiList: [
      'getNetworkType',
      'previewImage'
    ],
    success: function (res) {
      alert(JSON.stringify(res));
    }
  });
};

var images = {
		    localId: [],
		    serverId: []
		  };

document.querySelector('#chooseImage').onclick = function () {
  wx.chooseImage({
	count: 1, // 默认9
	sizeType: ['compressed'], 
	sourceType: ['camera'],
    success: function (res) {
      images.localId = res.localIds;
      alert('已选择 ' + res.localIds.length + ' 张照片');
    }
  });
};


document.querySelector('#uploadImage').onclick = function () {
	    if (images.localId.length == 0) {
	      alert('还没有选择图片');
	      return;
	    }
	    var i = 0, length = images.localId.length;
	   
	    images.serverId = [];
	    function upload() {
	      wx.uploadImage({
	        localId: images.localId[i],
	        success: function (res) {
	          i++;
	          alert('已上传：' + i + '/' + length);
	          images.serverId.push(res.serverId);
	          $('#imgIds').val(images.serverId.join());
	          if (i < length) {
	            upload();
	          }
	        },
	        fail: function (res) {
	          alert(JSON.stringify(res));
	        }
	      });
	    }
	    upload();
	    
	  };





document.querySelector('#getLocation').onclick = function () {
  wx.getLocation({
    type: 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
    success: function (res) {
      //alert(JSON.stringify(res));
      $('#longitude').val(res.longitude);
      $('#latitude').val(res.latitude);
      alert('获取位置成功');
    },
    cancel: function (res) {
      alert('用户拒绝授权获取地理位置');
    }
  });
};


});

wx.error(function (res) {
alert(res.errMsg);
});

</script>



</html>